/**
 * 
 */
function Score(mid, kor, eng){
	this.mid = mid;
	this.kor = kor;
	this.eng = eng;
	this.tot=0;
	this.avg=0;
	// 계산 
	this.compute = function(){
		this.tot = this.kor + this.eng;
		this.avg = this.tot/2;
	}
	// 게터 생성 
	this.getTot = function() {return this.tot;}
	this.getAvg = function() {return this.avg;}	
}

	array = new Array();

function ObjectInit(){
	document.getElementById("btn1").onclick = btn1Func;
	document.getElementById("btn2").onclick = btn2Func;
}

function btn1Func(){	
	var f = document.frm;
	
	var a = f.mid.value;			// 이름
	var b = Number(f.kor.value);	// 국어
	var c = Number(f.eng.value);	// 영어		
	
	var s = new Score(a,b,c);
		
	s.compute();
	
	array.push(s);
	
	alert(a + "님의 성적이 입력되었습니다.");
	
	f.tot.value = s.getTot();
	f.avg.value = s.getAvg();	
	
}

function btn2Func(){
	var f = document.frm;
	f.result.value = "";
	f.result.value = "순번" + "\t"+ "이름" + "\t" + "국어" + "\t" + "영어" + "\t" +
	"총점" + "\t" + "평균" + "\n";
	for(a=0; a<array.length; a++){
   		f.result.value += (a+1) + "번  " + "\t" + array[a].mid + "\t" + array[a].kor + "\t" + array[a].eng + "\t" +
   		array[a].getTot() + "\t" + array[a].getAvg() + "\n";
   	}
}